//
//  NHBaseTableHeaderFooterView.m
//  LZNeiHan
//
//  Created by 梁梓烽 on 16/10/2.
//  Copyright © 2016年 liangzifeng. All rights reserved.
//

#import "NHBaseTableHeaderFooterView.h"

@implementation NHBaseTableHeaderFooterView

/** 非xib 得到一个UITableViewHeaderFooterView */
+(instancetype)headerFooterViewWithTableView:(UITableView *)tableView
{
    if (tableView == nil) {
        return  [[self  alloc]init];
    }
    
    NSString *className = NSStringFromClass([self class]);
    NSString *identifier = [className stringByAppendingString:@"headerFooterCellID"];
    
    [tableView registerClass:[self class] forHeaderFooterViewReuseIdentifier:identifier];
    return  [tableView dequeueReusableHeaderFooterViewWithIdentifier:identifier];
}

/** xib UITableViewHeaderFooterView*/
+(instancetype)nibHeaerFooterViewWithTableView:(UITableView *)tableView
{
    if (tableView == nil) {
        return
        [[[NSBundle mainBundle]loadNibNamed:NSStringFromClass([self class]) owner:nil options:nil]firstObject];
    }
   
    NSString *className = NSStringFromClass([self class]);
    NSString *nibidentifier = [className stringByAppendingString:@"nibheaderFooterCellID"];
    
    
    [tableView registerNib:[UINib nibWithNibName:NSStringFromClass([self class]) bundle:nil] forHeaderFooterViewReuseIdentifier:nibidentifier];
    
    return [tableView dequeueReusableHeaderFooterViewWithIdentifier:nibidentifier];
}

    

@end
